package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.service.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 杨林
 * @create 2023-01-28 11:10 星期六
 * description:
 */
@RestController
@RequestMapping("/goodsType")
public class GoodsTypeController {

    @Autowired
    GoodsTypeService goodsTypeService;

    /**
     * 查询商品分类
     * @return：json字符串
     */
    @PostMapping("/loadGoodsType")
    public String loadGoodsType(){
        return goodsTypeService.loadGoodsType();
    }

    /**
     * 新增分类
     * @param goodsTypeName
     * @param pId
     * @return
     */
    @PostMapping("/save")
    public ServiceVO save(String goodsTypeName,
                          Integer pId){
        return goodsTypeService.save(goodsTypeName,pId);
    }


    /**
     * 删除分类
     * @param goodsTypeId
     * @return
     */
    @PostMapping("/delete")
    public ServiceVO delete(Integer goodsTypeId){

        return goodsTypeService.delete(goodsTypeId);
    }

}
